/**
 * @date 4:57:18 PM
 * Result.java
 * Administrator
 * TODO
 */
package com.qs.education.bean.exception;

import java.util.HashMap;
import java.util.Map;

/**
 * @class Result
 * @author Brooks
 * @description 
 * @date Oct 23, 2018
 */
public class ResultCode extends HashMap<String, Object>{
	
    private static final long serialVersionUID = 1L;

    public ResultCode()
    {
        put("code", 200);
        put("msg", "success");
    }

    public static ResultCode error()
    {
        return error(500, "未知异常，请联系管理员");
    }

    public static ResultCode error(String msg)
    {
        return error(500, msg);
    }

    public static ResultCode error(int code, String msg)
    {
    	ResultCode r = new ResultCode();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static ResultCode ok(String msg)
    {
    	ResultCode r = new ResultCode();
        r.put("msg", msg);
        return r;
    }

    public static ResultCode ok(Map<String, Object> map)
    {
    	ResultCode r = new ResultCode();
        r.putAll(map);
        return r;
    }

    public static ResultCode ok()
    {
        return new ResultCode();
    }

    public ResultCode put(String key, Object value)
    {
        super.put(key, value);
        return this;
    }
}

